package com.drought.rained.utils;

import android.app.Activity;
import android.content.Intent;
import android.net.Uri;
import android.text.TextUtils;

public class ApkUtilsLJ {

    /**
     * @param activity
     * @param appPkg  应用的包名
     */
    public static void launchAppDetail(Activity activity, String appPkg) {
        final String GOOGLE_PLAY = "com.android.vending";//谷歌商店
        try {
            if (TextUtils.isEmpty(appPkg))
                return;
            Uri uri = Uri.parse("market://details?id=" + appPkg);
            Intent intent = new Intent(Intent.ACTION_VIEW, uri);
            intent.setPackage(GOOGLE_PLAY);
            intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
            activity.startActivity(intent);
        } catch (Exception e) {
            Intent intent = new Intent();
            intent.setAction(Intent.ACTION_VIEW);
            Uri content_url = Uri.parse("https://play.google.com/store/apps/details?id=" + appPkg);
            intent.setData(content_url);
            activity.startActivity(intent);
        }
    }
}
